package org.goldenport.g3.messages

import org.goldenport.g3._

/**
 * @since   Jan.  9, 2011
 * @version Jun. 27, 2011
 * @author  ASAMI, Tomoharu
 */
abstract class RecordFieldException(cause: Exception = null) extends RuntimeException {
  if (cause != null) {
    initCause(cause)
  }

  def toMessage(ctx: String, cmd: G3Command): String
}

class MissingFieldRecordFieldException extends RecordFieldException {
  def toMessage(ctx: String, cmd: G3Command) = {
    "Missing field" // XXX
  }
}

class IllegalFormatRecordFieldException(cause: Exception) extends RecordFieldException(cause) {
  def toMessage(ctx: String, cmd: G3Command) = {
    "Illegal format: " + cause.getMessage // XXX
  }
}

class InvalidValueRecordFieldException(message: String) extends RecordFieldException {
  def toMessage(ctx: String, cmd: G3Command) = {
    "Invalid value: " + message // XXX
  }
}

class MultiplicityRecordFieldException(message: String) extends RecordFieldException {
  def toMessage(ctx: String, cmd: G3Command) = {
    "Invalid value: " + message // XXX
  }
}
